home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-23 | 2.6 KB | 61 lines | [TEXT/KAHL] |
- // =============================================================================
- // KEYQUENCER EXTENSIONS SAMPLE PROJECT HEADER - VERSION 1.2.1 - NOVEMBER 1994
- // ©1994 Alessandro Levi Montalcini <LMontalcini@pmn.it>
- // Don’t forget to send me any cool extensions you create!
- // This text looks best in monaco 9 font, 4 spaces per tab, no wrapping
-
- #ifndef _H_action
- #define _H_action
-
- // =============================================================================
- // The Extension.c file provides a simple way to set up your globals
- // and dispatch the extension messages. You don't have to call SetUpA4() or
- // RestoreA4() in the init() and run() routines because the main() routine in
- // the Extension.c file has done all the dirty work for you.
- // You can use the Extension.c file without modifications and add your own
- // code to the Action.c file, inside the existing init() and run() routines.
- // =============================================================================
- // PROTOTYPES:
-
- short run (ParamsPtr params, MachineHandle mac, GluePtr glue);
- short init (MachineHandle mac, GluePtr glue);
-
- long SetupExtensionWorld (void);
- void RestoreExtensionWorld (long world);
-
- // =============================================================================
- // The SetupExtensionWorld and RestoreExtensionWorld are needed if you
- // install patches or callbacks that may be called by the system and still
- // want to access your extension globals. Here's an example of how to do it:
- /*
-
- long gOldTrapAddress; // this is a global variable (the original trap address)
-
- short init(MachineHandle mac, GluePtr glue) // this is your extension's init() routine
- {
- gOldTrapAddress = (long)GetToolTrapAddress(_TheTrapToPatch);
- SetToolTrapAddress((UniversalProcPtr)MyTrapPatch, _TheTrapToPatch);
- return kExtNoError;
- }
-
- pascal void MyTrapPatch(void) // this is your trap patch
- { // (usually declared as pascal for toolbox traps)
- pascal void (*OriginalTrap)(void);
- long world;
-
- world = SetupExtensionWorld(); // get access to your extension's globals
-
- // you may use your globals here
-
- OriginalTrap = (void*)gOldTrapAddress; // gOldTrapAddress won't be available after RestoreExtensionWorld()
- RestoreExtensionWorld(world); // but the local variable will be OK
- (*OriginalTrap)(); // this is both a head and a tail patch, which is a Bad Thing
- } // (you have to use some assembler to avoid it)
-
- */
- // =============================================================================
-
- #endif // _H_action
-
- // =============================================================================
-